02. Forking A Repository
Forking a Repository - What Is Forking
In version control terminology if you "fork" a repository that means you duplicate it. Typically you fork a repository that belongs to someone else. So you make an identical copy of their repository and that duplicate copy now belongs to you.
This concept of "forking" is also different from "cloning". When you clone a repository, you get an identical copy of the repository. But cloning happens on your local machine and you clone a remote repository. When you fork a repository, a new duplicate copy of the remote repository is created. This new copy is also a remote repository, but it now belongs to you.
A fork
Subcommand?
Forking is not done on the command line; there is no git fork
command. Go ahead, try running the following command:
$ git fork
As you can see, trying to run the git fork
command produces an error. (Also, fsck
is not a rude word, it means "filesystem check" and refers to auditing the files for consistency.)
Alter a Cloned Repo
Task Description:
Do the following steps and answer the question below.
Task Feedback:
Great job doing each of these steps! Now answer the following question.
SOLUTION:
NoSOLUTION:
unable to accessWe can see from this little experiment that if a repository doesn't belong to your account then it means you do not have permission to modify it.
This is where forking comes in! Instead of modifying the original repository directly, if you fork the repository to your own account then you will have full control over that repository.
Forking Lam's Project
I'm going to clone Lam's project myself. My account does not have permission to edit her repository directly, so I'll fork the repository to my own account.
Task Description:
I want you to sign into your GitHub account and follow along with the rest of these steps:
Task Feedback:
Great job doing each of these steps!
Let's take a look at the name of the repository:
See how this shows my account name (richardkalehoff) and the name of the repository? But then just beneath that it says "forked from udacity/course-collaboration-travel-plans". This shows that this project is in my account but that it has a connection to the original project that it was copied from.
That's pretty neat, right?!? You can fork any public repository that's up on GitHub right now - which means you can get a copy of that repository in your own account that you will have total control over.
Why don't you go fork a few repositories just to get some practice! Here a few you can try it out on:
Push/Pull To The Fork
Because forking a repository gives you a copy of it in your account, you can clone at down to your computer, make changes to it, and then push those changes back to the forked repository. But you need to keep in mind that it'll be pushing the changes back to your remote repository not to the original remote repository that you forked from.
L2 - Pushing To A Fork
Recap
Forking is an action that's done on a hosting service, like GitHub. Forking a repository creates an identical copy of the original repository and moves this copy to your account. You have total control over this forked repository. Modifying your forked repository does not alter the original repository in any way.